﻿@model KL.Store.Web.Models.AddressListModel
@using KL.Store.Core
<ul>
    @foreach (var item in Model.AddressList)
    {
        <li class="address-height col-xs-12 col-sm-12 col-md-4 col-lg-3">
            <div class="address-height-inner">
                <b>@item.AddressName</b><br />

                @(Html.Raw(string.IsNullOrEmpty(item.Name) ? "" : item.Name + "<br />"))
                @(Html.Raw(string.IsNullOrEmpty(item.TaxOffice) ? "" : item.TaxOffice + "<br />"))
                @(Html.Raw(string.IsNullOrEmpty(item.TaxNo) ? "" : item.TaxNo + "<br />"))
                @(Html.Raw(string.IsNullOrEmpty(item.Phone) ? "" : item.Phone + "<br />"))
                @(Html.Raw(string.IsNullOrEmpty(item.Address1) ? "" : item.Address1 + "<br />"))
                @(Html.Raw(string.IsNullOrEmpty(item.Address2) ? "" : item.Address2 + " "))
                @(Html.Raw(string.IsNullOrEmpty(item.PostalCode) ? "" : item.PostalCode + "<br /><br />"))
                @(Html.Raw(string.IsNullOrEmpty(item.County) ? "" : item.County + " "))
                @(Html.Raw(string.IsNullOrEmpty(item.CityName) ? "" : item.CityName + " "))
                @(Html.Raw(string.IsNullOrEmpty(item.CountryName) ? "" : item.CountryName + " "))
                <br />
                <br />
                <div>
                    <a class="btn btn-custom1 addressEdit" onclick="updateAddress(@item.AddressId)" href="#address-update">Düzenle</a>
                    <a class="btn btn-custom1" onclick="deleteAddress(@item.AddressId)">Sil</a>
                </div>
            </div>
        </li>
    }
</ul>
<div class="clearfix"></div>
<br />
<div class="col-sm-12 first last">
    <a class="btn btn-custom1 addressEdit" onclick="updateAddress(0)" href="#address-update">Yeni Adres Oluştur</a>
</div>
@if (Parameters.Theme == "JJ")
{
    <script>
        $(document).ready(function ()
        {
            if ($(window).width() < 980)
            {
                $(".breadcrumb").parent().attr("class", $(".breadcrumb").parent().attr("class") + " first last");
            }
        });
    </script>
}
<script type="text/javascript">
    function updateAddress(id)
    {
        //$("#dialog-form").load("/Address/Update", { Id2: id });
        //$("#dialog-form").dialog("open");
        $("#address-update").html('').load("/Address/Update", { Id2: id });
    }
    function deleteAddress(id)
    {
        var answer = confirm("Adres silinecektir.  Devam edilsin mi?")
        if (answer)
        {
            $('#divAddress').load('/Address/Delete', { Id: id });
        }
        return false;
    }
    $(document).ready(function ()
    {
        var lBoxWidth = 525;
        if ($(document).width() < 525)
        {
            var lBoxWidth = '100%';
        }
        $(".addressEdit").fancybox({
            width: lBoxWidth,
            fitToView: false,
            autoSize: false,
            autoDimensions: false,
            autoScale: false,
            afterClose: function ()
            {
                $('#divAddress').load('/Address/Get');
            }
        });

        var enYuksekAdres = 0;
        $("#divAddress ul li").each(function ()
        {
            if ($(this).height() > enYuksekAdres)
            {
                enYuksekAdres = $(this).height();
            }
        });
        $("#divAddress ul li").height(enYuksekAdres + 3);
        $("#divAddress ul li .address-height-inner").height(enYuksekAdres);
    });
</script>
